import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;

public class PluginLoader {
    public static WeaponPlugin loadWeapon(String jarPath, String className) throws Exception {
        URL jarUrl = new File(jarPath).toURI().toURL();
        try (URLClassLoader loader = new URLClassLoader(new URL[]{jarUrl})) {
            Class<?> pluginClass = loader.loadClass(className);
            return (WeaponPlugin) pluginClass.newInstance();
        }
    }
}
